<?php
namespace Deployer;

require 'recipe/common.php';

// Project name
set('application', 'hello_world');

// Project repository
set('repository', 'https://gitee.com/terranc/hello_world.git');

// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', false);

// Shared files/dirs between deploys
set('shared_files', []);
set('shared_dirs', []);

// Writable dirs by web server
set('writable_dirs', []);

set('allow_anonymous_stats', false);
set('writable_use_sudo', false);

set('keep_releases', 5);

set('default_stage', 'dev');

task('composer:setting', function () {
    set('composer_options', '{{composer_action}} --verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader --no-suggest');
})->onStage('dev', 'fix');

// Hosts
host('dev')
    ->hostname('118.31.120.114')
    ->user('deployer')
    ->set('http_user', 'www')
    ->forwardAgent(true)
    ->multiplexing(true)
    ->set('branch', 'master')
    ->set('deploy_path', '/data/wwwroot/test');

host('fix')
    ->hostname('118.31.120.114')
    ->user('deployer')
    ->set('http_user', 'www')
    ->forwardAgent(true)
    ->multiplexing(true)
    ->set('branch', 'fix')
    ->set('deploy_path', '/data/wwwroot/test-fix');


// Tasks

desc('Deploy your project');
task('deploy', [
    'deploy:info',
    'deploy:prepare',
    'deploy:lock',
    'deploy:release',
    'deploy:update_code',
    'deploy:shared',
    'deploy:writable',
    'deploy:vendors',
    'deploy:clear_paths',
    'deploy:symlink',
    'deploy:unlock',
    'cleanup',
    'success'
]);

// [Optional] If deploy fails automatically unlock.
before('deploy:vendors', 'composer:setting');
after('deploy:failed', 'deploy:unlock');
